Tree-sitter: only update range and reparse for changed ranges
authorYuan Fu <casouri@gmail.com>
Fri, 19 Apr 2024 07:18:03 +0000 (00:18 -0700)
committerYuan Fu <casouri@gmail.com>
Sat, 20 Apr 2024 02:05:16 +0000 (19:05 -0700)
commitf62c1b4cd00e5b2f1cdc94796cf55d006c3113eb
tree89f02eea02225186e0a236138a77e673ffdde1d5
parent996b9576713f9d63ea7ff7e9630a15cb0a0214eb
Tree-sitter: only update range and reparse for changed ranges

In the very beginning, there's bug#66732, to solve that bug, we added
treesit--pre-redisplay and treesit--syntax-propertize-notifier.
However, to fix bug#66732, we were updating ranges for the whole
buffer which makes Emacs extremely slow when there are a lot of local
parsers in a large buffer.  Then to solve that we introduced a
workaround where we only update ranges in a fixed range around point.

This change fixes the original problem (bug#66732) without using that
workaround.

* lisp/treesit.el (treesit--font-lock-notifier):
(treesit--syntax-propertize-notifier): Remove functions
(treesit--pre-redisplay): Use the new function
treesit-parser-changed-ranges to get the changed ranges of the primary
parser, and only update ranges for those ranges.  Plus do the work of
the removed function.
(treesit-major-mode-setup): Remove setup for the removed functions.
lisp/treesit.el